#ifndef COMMANPAGE_H
#define COMMANPAGE_H

#include <QWidget>
#include <musiclist.h>
#include <QMediaPlaylist>

namespace Ui {
class CommanPage;
}

//设置页面类型
enum PageType
{
    PAGE_LIKE,
    PAGE_LOCAL,
    PAGE_HISTORY
};

class CommanPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommanPage(QWidget *parent = nullptr);
    ~CommanPage();

    void setCommanPageUi(const QString& text , const QString& imagePath);

    void setPageType(PageType pageType);

    void setMusicImage(QPixmap pixmap);

    void reFresh(MusicList& musicList);

    void addMusicToPlayer(MusicList& musicList , QMediaPlaylist* playList);

    QString getMusicIdByIndex(int index);

signals:
    void updateLikeMusic(bool ,QString);
    void playAll(PageType pageType);
    void playMusicByIndex(CommanPage* page , int index);

private:
    void addMusicToMusicPage(MusicList& musicList);

private:
    Ui::CommanPage *ui;

    PageType _pageType;

    //存放musicID
    QVector<QString> musicOfPage;
};

#endif // COMMANPAGE_H
